<template>
	<view class="page-container">
		<uni-list class="table-view-group">
		    <uni-list-item title="绑定手机" :rightText="userInfo.mobile ? userInfo.mobile : '请绑定'" @click="bindPhone"></uni-list-item>
		    <uni-list-item title="实名认证" :rightText="verifyArr[userInfo.verifystatus]" @click="realName"></uni-list-item>
		</uni-list>
		
		<view class="logout-btn-block" @click="logout">退出登录</view>
		
	</view>
</template>

<script>
	import uniList from "@/components/uni-list/uni-list.vue"
	import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
	import {isWxClient} from '@/utils/utils.js'
	export default {
	    components: {
			uniList,
			uniListItem
		},
		data() {
			return {
				userInfo: {},
				verifyArr:['前往认证','审核中','已认证','未通过']
			}
		},
		onShow() {
			this.$_init();
		},
		methods: {
			//退出登录
			logout(){
				uni.showModal({
					title: '确认退出登录',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确认',
					success: res => {
						if( res.confirm ){
							//确认
							uni.removeStorageSync('userInfo');
							uni.removeStorageSync('token');
							this.$store.commit('logout');
							
							// 微信快速登录退出
							let iswx= isWxClient()
							if (iswx) {
								uni.setStorageSync('loginWxClientStatus',false);
							}
							
							uni.switchTab({
								url:'/pages/ucenter/index'
							});
						}
					}
				});
			},
			
			// 初始化页面数据
			async $_init(){
				let params = {
					method: "api/v2/member/info/show"
				};
				let res = await this.$http(params)
				if( res.data ){
					this.userInfo = res.data;
				}
				
			},
			
			// 绑定手机
			bindPhone(){
				uni.navigateTo({
					url: './phone'
				})
			},
			
			// 实名认证
			realName(){
				uni.navigateTo({
					url: './realname?verifystatus='+this.userInfo.verifystatus
				})
			}
			
		}
	}
</script>

<style lang="scss">
	.page-container{
		padding: 24rpx;
	}
	.table-view-group{
		margin-bottom: 20rpx;
		border-radius: $uni-border-radius-lg;
	}
	.logout-btn-block{
		color: $uni-text-color-inverse;
		padding: 22rpx 0;
		text-align: center;
		margin-top: 40rpx;
		font-size: $uni-font-size-lg;
		border-radius: $uni-border-radius-lg;
		background-color: $uni-bg-color-primary;
	}
	
</style>
